<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:define name="title">
	<h:outputText value="#{lang.LIST_COLLABORATOR}" />
</ui:define>

<body>
	<ui:composition template="layout.xhtml">
		
		<ui:define name="menuBody">
			<ui:include src="adminMenu.xhtml"></ui:include>
		</ui:define>
		<ui:define name="newHeader">
			<h:form enctype="multipart/form-data">
				<p:fileUpload
					fileUploadListener="#{fileUploadController.handleFileUpload}"
					mode="advanced" update=":collaboratorDataTable" multiple="true"
					sizeLimit="100000" allowTypes="/(\.|\/)(xls|xlsx)$/" style="font-size : 0.7em"  />

				<p:growl id="messages" showDetail="true" />

			</h:form>
			
		</ui:define>
		<ui:define name="contentHeader">
			
			<h:outputText value="#{lang.LIST_COLLABORATOR}" />
		</ui:define>
		<ui:define name="contentBody">
		
		
				<p:dataTable id="collaboratorDataTable"
					value="#{collaboratorsBean.collaborators}" var="item"
					rowStyleClass="data-grid-content" tableStyleClass="data-grid"
					sortBy="#{item.das}" paginator="true" rows="8">

					<p:column headerText="#{lang.DAS}" id="das" sortBy="#{item.das}">
						<h:outputText value="#{item.das}" />
					</p:column>
					<p:column headerText="#{lang.LASTNAME}" id="nom"
						sortBy="#{item.lastName}">
						<h:outputText value="#{item.lastName}" />

					</p:column>
					<p:column headerText="#{lang.FIRSTNAME}" id="prenom"
						sortBy="#{item.firstName}">
						<h:outputText value="#{item.firstName}" />
					</p:column>
					<p:column headerText="#{lang.RULE}" id="rule" sortBy="#{item.rule}">
						<h:outputText value="#{lang[item.rule]}" />
					</p:column>
					<p:column headerText=" " style="width:100px">
						<h:form>
						<p:commandButton icon="ui-icon-edit"
							oncomplete="editCol.show()" 
							process="@this"
							update=":editColab"
							>
						<f:setPropertyActionListener target="#{collaboratorsBean.selectedCollaborator}" value="#{item}"  ></f:setPropertyActionListener>
						</p:commandButton>
						
						<p:spacer width="5px"></p:spacer>
						<p:commandButton icon="ui-icon-delete"
							onclick="return confirm('#{lang.CONFIRM_DELETE_COLLABORATOR} ?');"
							action="#{collaboratorsBean.deleteCollaborator(item)}">
						</p:commandButton>
						</h:form>
					</p:column>
					
				</p:dataTable>
				
				<br />
				<br />
				
				<p:dialog id="editColab"  widgetVar="editCol" header="#{lang.UPDATE_COLLABORATOR}"
				resizable="false" showEffect="clip" hideEffect="clip">
				<h:form>
	            <table cellpadding="0" cellspacing="12" border="0" width="500">
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.DAS}" /></td>
								<td align="left"><h:outputText id="dasE" size="10"
										styleClass="fields"
										value="#{collaboratorsBean.selectedCollaborator.das}" required="true">
									</h:outputText> <h:message for="dasE" /></td>
							</tr>
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.LASTNAME}" /></td>
								<td align="left"><p:inputText id="lastNameE"
										styleClass="fields"
										value="#{collaboratorsBean.selectedCollaborator.lastName}"
										required="true">
									</p:inputText> <h:message for="lastNameE" /></td>
							</tr>
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.FIRSTNAME}" /></td>
								<td align="left"><p:inputText id="firstNameE"
										styleClass="fields"
										value="#{collaboratorsBean.selectedCollaborator.firstName}"
										required="true">
									</p:inputText> <h:message for="firstNameE" /></td>
							</tr>
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.PASSWORD}" /></td>
								<td align="left"><p:password id="passwordE"
										value="#{collaboratorsBean.selectedCollaborator.password}"
										feedback="true" promptLabel="#{lang.PASSWORD_PROMPT_LABEL}"
										weakLabel="#{lang.PASSWORD_WEAK_LABEL}"
										goodLabel="#{lang.PASSWORD_GOOD_LABEL}"
										strongLabel="#{lang.PASSWORD_STRONG_LABEL}" /> <h:message
										for="passwordE" /></td>
							</tr>
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.EMAIL}" /></td>
								<td align="left"><p:inputText id="emailE"
										styleClass="fields"
										value="#{collaboratorsBean.selectedCollaborator.email}" required="true">
									</p:inputText> <h:message for="emailE" /></td>
							</tr>
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.BIRTHDAY}" /></td>
								<td align="left"><p:calendar styleClass="datepicker"
										showButtonPanel="true" navigator="true" id="birthdayE"
										required="true"
										maxdate="5/3/2000"
										value="#{collaboratorsBean.selectedCollaborator.birthday}"></p:calendar>
									<h:message for="birthdayE" /></td>
							</tr>
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.NATIONALITY}" /></td>
								<td align="left"><p:inputText id="nationalityE"
										styleClass="fields"
										value="#{collaboratorsBean.selectedCollaborator.nationality}"
										required="true">
									</p:inputText> <h:message for="nationalityE" /></td>
							</tr>
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.SEX}" /></td>
								<td align="left">
								<p:selectOneRadio id="sexE"
										value="#{collaboratorsBean.selectedCollaborator.sex}">
										<f:selectItem itemLabel="#{lang.SEX_F}" itemValue="Female"></f:selectItem>
										<f:selectItem itemLabel="#{lang.SEX_M}" itemValue="Male"></f:selectItem>
								</p:selectOneRadio> <h:message for="sexE" /></td>
							</tr>
							<tr>
								<td class="auth-label" width="200"><h:outputText
										value="#{lang.RULE}" /></td>
								<td align="left">
								<p:selectOneMenu id="ruleE"
										value="#{collaboratorsBean.selectedCollaborator.rule}">
										<f:selectItems value="#{ruleBean.ruleValues}"  var="rule" itemValue="#{rule}" itemLabel="{lang[rule.value]}" />
								</p:selectOneMenu> 
								<h:message for="ruleE" /></td>
							</tr>
						
							<tr>
								<td colspan="2">
								<h:commandButton value="#{lang.SAVE}" action="#{collaboratorsBean.updateCollaborator}"
									></h:commandButton></td>
							</tr>
						</table>
						</h:form>
		     	</p:dialog>
			<br />
			<br />
			<br />
			<br />

		</ui:define>

	</ui:composition>
</body>
</html>